package myblc

type Blockchain struct {
	Blocks []*Block //存储有序的区块
}


//创建带有创世区块的区块链
func CreateBlockchainWithGenesisBlock() *Blockchain {
	genesisBlock := CreateGenesisBlock("shang gu wen du")
	blockchain := &Blockchain{[]*Block{genesisBlock}}
	return blockchain
}

//增加区块到区块链
func (blc *Blockchain) AddBlockToBlockchain(data string, height int64, prevBlcokHash []byte)  {
	newBlock := NewBlock(data, height, prevBlcokHash)
	blc.Blocks = append(blc.Blocks, newBlock)
}
